package com.lx.oms.controller.manager.impl;

import java.math.BigInteger;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.lx.oms.common.entity.Page;
import com.lx.oms.common.entity.Query;
import com.lx.oms.common.utils.Utils;
import com.lx.oms.controller.dao.UserPersonalMapper;
import com.lx.oms.controller.entity.UserPersonalEntity;
import com.lx.oms.controller.manager.UserPersonalManager;

/**
 * 个人
 *
 * @author houzhong
 * @date 2018年7月10日 下午3:10:22
 */
@Component("userPersonalManager")
public class UserPersonalManagerImpl implements UserPersonalManager {

	@Autowired
	private UserPersonalMapper userPersonalMapper;
	
	@Override
	public List<UserPersonalEntity> listUserPersonal(Page<UserPersonalEntity> page, Query search) {
		return userPersonalMapper.listForPage(page, search);
	}

	@Override
	public int saveUserPersonal(UserPersonalEntity userPersonal) {
		if (userPersonal.getId() == null) {
			userPersonal.setId(Utils.id().toString());
		}
		return userPersonalMapper.save(userPersonal);
	}

	@Override
	public UserPersonalEntity getUserPersonalById(BigInteger id) {
		UserPersonalEntity userPersonal = userPersonalMapper.getObjectById(id);
		return userPersonal;
	}

	@Override
	public int updateUserPersonal(UserPersonalEntity userPersonal) {
		return userPersonalMapper.update(userPersonal);
	}

	@Override
	public int batchRemove(String[] id) {
		int count = userPersonalMapper.batchRemove(id);
		return count;
	}
	
}
